package com.sjsd.hdfs;

public class Driver {
    public static void main(String[] args) {
        try{
            if (args == null || args.length  <  4) {
                throw new Exception("输入参数错误");
            }else {
                if (args[0].equals("-r")) {
                    try {
                        HDFS.hdfsReadFile(args[1],args[2],args[3]);
                    }catch (Exception e) {
                        System.out.printf(e.getMessage());
                    }
                }else if(args[0].equals("-w")) {
                    try{
                        HDFS.hdfsWrite(args[1],args[2],args[3]);

                    }catch (Exception e) {
                        System.out.printf(e.getMessage());
                    }
                } else {
                    throw new Exception("参数输入错误");
                }
            }


        }catch (Exception e) {
            //用法
            System.out.println("java -jar hdfs.jar -r hdfsFile hdfsUrl localFile -- to read a file from HDFS and write as a local file");
            System.out.println("java -jar hdfs.jar -w localFile hdfsUrl hdfsFile -- to write a hdfs from a local file");
        }

    }
}
